/////////////////////////////////////////////////////
//	File:		InstructionState.cpp
//	Class:		SGP
//	Updated:	3/6/2012
//	Author:		Roc Myers
//	Purpose:	To contain all Help Menu related code
/////////////////////////////////////////////////////

#include "MainMenuState.h"
#include "Game.h"
#include "HowToPlayState.h"
#include "TutorialPlayState.h"
#include "SGD Wrappers\CSGD_TextureManager.h"
#include "SGD Wrappers\CSGD_DirectInput.h"
#include "SGD Wrappers\CSGD_XAudio2.h"
HowToPlayState* HowToPlayState::pInstance = nullptr;


HowToPlayState::HowToPlayState(void)
{
	BGMID			= -1;
	CursorID		= -1;
	BackgroundID	= -1;
	FontID			= -1;
	LeftID			= -1;
	RightID			= -1;
	UpID			= -1;
	DownID			= -1;
	EnterID			= -1;
	EscID			= -1;
	ShiftID			= -1;
	TileSheet		= -1;
	declineID		= -1;
	acceptID		= -1;
	errorID			= -1;
	moveID			= -1;
	PanelID			= -1;
}

HowToPlayState& HowToPlayState::operator=(const HowToPlayState&)
{
	return *this;
}

HowToPlayState::~HowToPlayState(void)
{
}

HowToPlayState* HowToPlayState::GetInstance(void)
{
	if(pInstance == nullptr)
		pInstance = new HowToPlayState();

	return pInstance;
}

void HowToPlayState::DeleteInstance()
{
	if(pInstance != nullptr)
	{
		delete pInstance;
		pInstance = nullptr;
	}
}

void HowToPlayState::Enter(void)
{
	BGMID	= CSGD_XAudio2::GetInstance()->MusicLoadSong(_T("resource/Tutorial.xwm"));
	CursorID = CSGD_TextureManager::GetInstance()->LoadTexture(_T("resource/SGD_MenuCursor.png"),D3DCOLOR_XRGB(0,0,0));
	FontID = CSGD_TextureManager::GetInstance()->LoadTexture(_T("resource/LARPFont.png"));
	BackgroundID = CSGD_TextureManager::GetInstance()->LoadTexture(_T("resource/OtherBack.jpg"));
	LeftID = CSGD_TextureManager::GetInstance()->LoadTexture(_T("resource/LeftArrow.png"));
	RightID = CSGD_TextureManager::GetInstance()->LoadTexture(_T("resource/RightArrow.png"));
	UpID = CSGD_TextureManager::GetInstance()->LoadTexture(_T("resource/UpArrow.png"));
	DownID = CSGD_TextureManager::GetInstance()->LoadTexture(_T("resource/DownArrow.png"));
	EnterID = CSGD_TextureManager::GetInstance()->LoadTexture(_T("resource/Enter.png"));
	EscID = CSGD_TextureManager::GetInstance()->LoadTexture(_T("resource/Escape.png"));
	ShiftID = CSGD_TextureManager::GetInstance()->LoadTexture(_T("resource/Shift.png"));
	DiceID = CSGD_TextureManager::GetInstance()->LoadTexture(_T("resource/CJDiceSheet.bmp"));
	TileSheet = CSGD_TextureManager::GetInstance()->LoadTexture(_T("resource/mockTileSet.bmp"));
	declineID	= CSGD_XAudio2::GetInstance()->SFXLoadSound(_T("resource/soundFX/GUI/GUI_InGame_Decline.wav"));
	acceptID	= CSGD_XAudio2::GetInstance()->SFXLoadSound(_T("resource/soundFX/GUI/GUI_InGame_Accept.wav"));
	errorID		= CSGD_XAudio2::GetInstance()->SFXLoadSound(_T("resource/soundFX/GUI/GUI_InGame_Error.wav"));
	moveID		= CSGD_XAudio2::GetInstance()->SFXLoadSound(_T("resource/soundFX/GUI/GUI_Main_Move.wav"));
	Selection = 0;
	Reference = false;
	Controls = false;
	Gameplay = false;
	Font.Initialize(FontID,"LARPFont.fnt");

	sfxVol	= Game::GetInstance()->SfxVol;
	bgmVol	= Game::GetInstance()->BgmVol;
	pan		= Game::GetInstance()->Pan;
	
	CSGD_XAudio2::GetInstance()->MusicSetSongPan(BGMID,pan);
	CSGD_XAudio2::GetInstance()->MusicPlaySong(BGMID,true);

	PanelID		= CSGD_TextureManager::GetInstance()->LoadTexture(_T("resource/HUD.png"));

	arcadeEnter = false;
	arcadeEscape = false;
	arcadeUp = false;
	arcadeDown = false;
	arcadeLeft = false;
	arcadeRight = false;
	arcadeBackspace = false;
	arcadeShift = false;
	arcadePlus = false;
	arcadeMinus = false;
	arcadeP = false;

}

bool HowToPlayState::Input(void)
{
	ArcadeInput();


	if(!Reference && !Controls && !Gameplay)
	{
		if(CSGD_DirectInput::GetInstance()->KeyPressed(DIK_ESCAPE)||arcadeEscape)
			Selection = 2;

		if(CSGD_DirectInput::GetInstance()->KeyPressed(DIK_UP)||arcadeUp)
		{
			CSGD_XAudio2::GetInstance()->SFXPlaySound(moveID);
			if(Selection > 0)
				Selection -= 1;
			else
				Selection = 2;
		}

		if(CSGD_DirectInput::GetInstance()->KeyPressed(DIK_DOWN)||arcadeDown)
		{
			CSGD_XAudio2::GetInstance()->SFXPlaySound(moveID);
			if(Selection < 2)
				Selection += 1;
			else
				Selection = 0;
		}

		if(CSGD_DirectInput::GetInstance()->KeyPressed(DIK_RETURN)||arcadeEnter)
		{
			CSGD_XAudio2::GetInstance()->SFXPlaySound(acceptID);
			switch(Selection)
			{
			case 0:
				{
					Selection = 0;
					Reference = true;
					break;
				}

		case 1:
			{
				if(CSGD_DirectInput::GetInstance()->KeyPressed(DIK_RETURN)||arcadeEnter)
					Game::GetInstance()->ChangeState(TutorialPlayState::GetInstance());
					break;
				}

			case 2:
				{
					Game::GetInstance()->ChangeState(MainMenuState::GetInstance());
					break;
				}
			};
		}
	}
	else if(Reference && !Controls && !Gameplay)
	{
		if(CSGD_DirectInput::GetInstance()->KeyPressed(DIK_UP)||arcadeUp)
		{
			CSGD_XAudio2::GetInstance()->SFXPlaySound(moveID);
			if(Selection > 0)
				Selection -= 1;
			else
				Selection = 2;
		}

		if(CSGD_DirectInput::GetInstance()->KeyPressed(DIK_DOWN)||arcadeDown)
		{
			CSGD_XAudio2::GetInstance()->SFXPlaySound(moveID);
			if(Selection < 2)
				Selection += 1;
			else
				Selection = 0;
		}

		if(CSGD_DirectInput::GetInstance()->KeyPressed(DIK_RETURN)||arcadeEnter)
		{
			CSGD_XAudio2::GetInstance()->SFXPlaySound(acceptID);
			switch(Selection)
			{
			case 0:
				{

					Controls = true;
					Reference = false;
					break;
				}

			case 1:
				{
					Gameplay = true;
					Reference = false;
					Selection = 0;
					break;
				}

			case 2:
				{
					Reference = false;
					Selection = 0;
					break;
				}
			};
		}
	}
	else if(Gameplay && !Reference && !Controls)
	{
		if(CSGD_DirectInput::GetInstance()->KeyPressed(DIK_RETURN)||arcadeEnter)
		{
			CSGD_XAudio2::GetInstance()->SFXPlaySound(acceptID);
			Gameplay = false;
			Reference = true;
			Selection = 0;
		}

		if(CSGD_DirectInput::GetInstance()->KeyPressed(DIK_LEFT)||arcadeLeft)
		{
			CSGD_XAudio2::GetInstance()->SFXPlaySound(moveID);
			if(Selection > 0)
				Selection -= 1;
			else
				Selection = 4;
		}

		if(CSGD_DirectInput::GetInstance()->KeyPressed(DIK_RIGHT)||arcadeRight)
		{
			CSGD_XAudio2::GetInstance()->SFXPlaySound(moveID);
			if(Selection < 4)
				Selection += 1;
			else
				Selection = 0;
		}
	}
	else if(Controls && !Reference && !Gameplay)
	{
		if(CSGD_DirectInput::GetInstance()->KeyPressed(DIK_RETURN)||arcadeEnter)
		{
			CSGD_XAudio2::GetInstance()->SFXPlaySound(acceptID);
			Controls = false;
			Reference = true;
			Selection = 0;
		}
	}
	return true;
}

void HowToPlayState::Update(float fElapsedTime)
{
}

void HowToPlayState::Render(void)
{
	RECT GUItop = {6, 6, 211, 34};
	RECT GUImid = {6, 45, 211, 92};
	RECT GUIbot = {6, 103, 211, 132};

	CSGD_TextureManager::GetInstance()->Draw(BackgroundID,0,-150,0.5f,0.5f);

	if(!Reference && !Controls && !Gameplay)
	{
		CSGD_TextureManager::GetInstance()->Draw(PanelID, 110, 35, 2.7f, 3.0f, &GUItop, 0.0f, 0.0f, 0.0f, D3DCOLOR_ARGB(255,255,255,255));
		CSGD_TextureManager::GetInstance()->Draw(PanelID, 110, 50, 2.7f, 3.0f, &GUIbot, 0.0f, 0.0f, 0.0f, D3DCOLOR_ARGB(255,255,255,255));

		CSGD_TextureManager::GetInstance()->Draw(PanelID, 130, 175, 2.5f, 2.0f, &GUItop, 0.0f, 0.0f, 0.0f, D3DCOLOR_ARGB(255,255,255,255));
		CSGD_TextureManager::GetInstance()->Draw(PanelID, 130, 230, 2.5f, 2.3f, &GUImid, 0.0f, 0.0f, 0.0f, D3DCOLOR_ARGB(255,255,255,255));
		CSGD_TextureManager::GetInstance()->Draw(PanelID, 130, 290, 2.5f, 2.5f, &GUIbot, 0.0f, 0.0f, 0.0f, D3DCOLOR_ARGB(255,255,255,255));

		Font.Print("How To Play", 150, 35, 3.0f);
		Font.Print("Quick Reference", 200, 175, 2.0f);
		Font.Print("Tutorial", 200, 235, 2.0f);
		Font.Print("Back", 200, 295, 2.0f);

		switch(Selection)
		{
		case 0:
			CSGD_TextureManager::GetInstance()->Draw(CursorID, 180, 205);
			break;
		
		case 1:
			CSGD_TextureManager::GetInstance()->Draw(CursorID, 180, 265);
			break;

		case 2:
			CSGD_TextureManager::GetInstance()->Draw(CursorID, 180, 325);
			break;
		};
	}
	else if(Reference && !Controls && !Gameplay)
	{

		CSGD_TextureManager::GetInstance()->Draw(PanelID, 110, 35, 2.7f, 3.0f, &GUItop, 0.0f, 0.0f, 0.0f, D3DCOLOR_ARGB(255,255,255,255));
		CSGD_TextureManager::GetInstance()->Draw(PanelID, 110, 50, 2.7f, 3.0f, &GUIbot, 0.0f, 0.0f, 0.0f, D3DCOLOR_ARGB(255,255,255,255));
		
		CSGD_TextureManager::GetInstance()->Draw(PanelID, 130, 175, 2.5f, 2.0f, &GUItop, 0.0f, 0.0f, 0.0f, D3DCOLOR_ARGB(255,255,255,255));
		CSGD_TextureManager::GetInstance()->Draw(PanelID, 130, 230, 2.5f, 2.3f, &GUImid, 0.0f, 0.0f, 0.0f, D3DCOLOR_ARGB(255,255,255,255));
		CSGD_TextureManager::GetInstance()->Draw(PanelID, 130, 290, 2.5f, 2.5f, &GUIbot, 0.0f, 0.0f, 0.0f, D3DCOLOR_ARGB(255,255,255,255));

		Font.Print("How To Play", 150, 35, 3.0f);
		Font.Print("Controls", 200, 175, 2.0f);
		Font.Print("Gameplay", 200, 235, 2.0f);
		Font.Print("Back", 200, 295, 2.0f);

		switch(Selection)
		{
		case 0:
			CSGD_TextureManager::GetInstance()->Draw(CursorID, 180, 205);
			break;
		
		case 1:
			CSGD_TextureManager::GetInstance()->Draw(CursorID, 180, 265);
			break;

		case 2:
			CSGD_TextureManager::GetInstance()->Draw(CursorID, 180, 325);
			break;
		};
	}
	else if(Controls && !Reference && !Gameplay)
	{
		CSGD_TextureManager::GetInstance()->Draw(PanelID, 190, 5, 2.0f, 1.5f, &GUItop, 0.0f, 0.0f, 0.0f, D3DCOLOR_ARGB(255,255,255,255));
		CSGD_TextureManager::GetInstance()->Draw(PanelID, 190, 35, 2.0f, 1.2f, &GUIbot, 0.0f, 0.0f, 0.0f, D3DCOLOR_ARGB(255,255,255,255));

		CSGD_TextureManager::GetInstance()->Draw(PanelID, 30, 85, 3.0f, 1.5f, &GUItop, 0.0f, 0.0f, 0.0f, D3DCOLOR_ARGB(255,255,255,255));
		CSGD_TextureManager::GetInstance()->Draw(PanelID, 30, 120, 3.0f, 1.0f, &GUImid, 0.0f, 0.0f, 0.0f, D3DCOLOR_ARGB(255,255,255,255));
		CSGD_TextureManager::GetInstance()->Draw(PanelID, 30, 160, 3.0f, 1.5f, &GUIbot, 0.0f, 0.0f, 0.0f, D3DCOLOR_ARGB(255,255,255,255));

		CSGD_TextureManager::GetInstance()->Draw(PanelID, 190, 220, 2.0f, 1.5f, &GUItop, 0.0f, 0.0f, 0.0f, D3DCOLOR_ARGB(255,255,255,255));
		CSGD_TextureManager::GetInstance()->Draw(PanelID, 190, 250, 2.0f, 1.2f, &GUIbot, 0.0f, 0.0f, 0.0f, D3DCOLOR_ARGB(255,255,255,255));

		CSGD_TextureManager::GetInstance()->Draw(PanelID, 30, 295, 3.7f, 2.0f, &GUItop, 0.0f, 0.0f, 0.0f, D3DCOLOR_ARGB(255,255,255,255));
		CSGD_TextureManager::GetInstance()->Draw(PanelID, 30, 350, 3.7f, 2.0f, &GUImid, 0.0f, 0.0f, 0.0f, D3DCOLOR_ARGB(255,255,255,255));
		CSGD_TextureManager::GetInstance()->Draw(PanelID, 30, 443, 3.7f, 2.0f, &GUIbot, 0.0f, 0.0f, 0.0f, D3DCOLOR_ARGB(255,255,255,255));

		// Controls screen
		Font.Print("Menu Controls", 230, 5, 2.0f);
		Font.Print("Up & Down Arrow Keys: Navigate Menu", 50, 95, 1.0f);
		Font.Print("Enter Key: Select Menu Item", 50, 145, 1.0f);
		CSGD_TextureManager::GetInstance()->Draw(UpID, 545, 100);
		CSGD_TextureManager::GetInstance()->Draw(DownID, 575, 100);
		CSGD_TextureManager::GetInstance()->Draw(EnterID, 395, 150);

		Font.Print("Game Controls", 230, 220, 2.0f);
		Font.Print("Arrow Keys: Move Cursor Around Grid", 50, 300, 1.0f);
		Font.Print("Enter Key: Select Player Character On Highlighted Tile", 50, 350, 1.0f);
		Font.Print("Escape Key: Pause & Unpause Game", 50, 400, 1.0f);
		Font.Print("Shift Keys: Stats Menu For Highlighted Character", 50, 450, 1.0f);
		Font.Print("Press Enter To Return", 120, 500, 2.0f);
		CSGD_TextureManager::GetInstance()->Draw(UpID, 500, 305);
		CSGD_TextureManager::GetInstance()->Draw(DownID, 534, 305);
		CSGD_TextureManager::GetInstance()->Draw(LeftID, 568, 305);
		CSGD_TextureManager::GetInstance()->Draw(RightID, 602, 305);
		CSGD_TextureManager::GetInstance()->Draw(EnterID, 680, 350);
		CSGD_TextureManager::GetInstance()->Draw(EscID, 480, 400);
		CSGD_TextureManager::GetInstance()->Draw(ShiftID, 630, 450);
	}
	else if(Gameplay && !Reference && !Controls)
	{
		switch(Selection)
		{
		case 0:
			{
				CSGD_TextureManager::GetInstance()->Draw(PanelID, 185, 5, 2.0f, 1.7f, &GUItop, 0.0f, 0.0f, 0.0f, D3DCOLOR_ARGB(255,255,255,255));
				CSGD_TextureManager::GetInstance()->Draw(PanelID, 185, 35, 2.0f, 2.2f, &GUIbot, 0.0f, 0.0f, 0.0f, D3DCOLOR_ARGB(255,255,255,255));

				CSGD_TextureManager::GetInstance()->Draw(PanelID, 80, 225, 3.0f, 1.5f, &GUItop, 0.0f, 0.0f, 0.0f, D3DCOLOR_ARGB(255,255,255,255));
				CSGD_TextureManager::GetInstance()->Draw(PanelID, 80, 255, 3.0f, 1.0f, &GUImid, 0.0f, 0.0f, 0.0f, D3DCOLOR_ARGB(255,255,255,255));
				CSGD_TextureManager::GetInstance()->Draw(PanelID, 80, 295, 3.0f, 1.5f, &GUIbot, 0.0f, 0.0f, 0.0f, D3DCOLOR_ARGB(255,255,255,255));

				// Instructions
				Font.Print("Gameplay", 230, 5, 3.0f);
				Font.Print("Use Left & Right", 180, 225, 2.0f);
				Font.Print("To Switch Topics", 180, 275, 2.0f);
				Font.Print("Press Enter To Return", 130, 515, 2.0f);
				break;
			}
		case 1:
			{
				CSGD_TextureManager::GetInstance()->Draw(PanelID, 170, 5, 2.0f, 1.5f, &GUItop, 0.0f, 0.0f, 0.0f, D3DCOLOR_ARGB(255,255,255,255));
				CSGD_TextureManager::GetInstance()->Draw(PanelID, 170, 45, 2.0f, 1.2f, &GUIbot, 0.0f, 0.0f, 0.0f, D3DCOLOR_ARGB(255,255,255,255));

				CSGD_TextureManager::GetInstance()->Draw(PanelID, 0, 85, 3.9f, 3.0f, &GUItop, 0.0f, 0.0f, 0.0f, D3DCOLOR_ARGB(255,255,255,255));
				CSGD_TextureManager::GetInstance()->Draw(PanelID, 0, 155, 3.9f, 3.0f, &GUImid, 0.0f, 0.0f, 0.0f, D3DCOLOR_ARGB(255,255,255,255));
				CSGD_TextureManager::GetInstance()->Draw(PanelID, 0, 248, 3.9f, 3.0f, &GUImid, 0.0f, 0.0f, 0.0f, D3DCOLOR_ARGB(255,255,255,255));
				CSGD_TextureManager::GetInstance()->Draw(PanelID, 0, 360, 3.9f, 3.0f, &GUImid, 0.0f, 0.0f, 0.0f, D3DCOLOR_ARGB(255,255,255,255));
				CSGD_TextureManager::GetInstance()->Draw(PanelID, 0, 500, 3.9f, 3.0f, &GUIbot, 0.0f, 0.0f, 0.0f, D3DCOLOR_ARGB(255,255,255,255));

				// General gameplay info
				Font.Print("General", 250, 10, 2.0f);
				Font.Print("The basic goal is to clear each map by either reaching a ", 20, 100, 1.0f);
				Font.Print("certain point on the map or defeating all of your opponents.", 20, 160, 1.0f);
				Font.Print("-Each character on your team can move and do one action per turn.", 20, 220, 1.0f);
				Font.Print("--If you perform an action first you may not move.", 20, 280, 1.0f);
				Font.Print("--Actions include using an item, ability, or basic attack.", 20, 340, 1.0f);
				Font.Print("-Characters will gain experience and possibly level up after a battle.", 20, 400, 1.0f);
				Font.Print("--The weather can change, causing various effects on the map.", 20, 460, 1.0f);
				Font.Print("--Some tiles may have positive or negative effects on characters.", 20, 520, 1.0f);
				break;
			}
		case 2:
			{
				CSGD_TextureManager::GetInstance()->Draw(PanelID, 190, 5, 1.5f, 1.5f, &GUItop, 0.0f, 0.0f, 0.0f, D3DCOLOR_ARGB(255,255,255,255));
				CSGD_TextureManager::GetInstance()->Draw(PanelID, 190, 45, 1.5f, 1.2f, &GUIbot, 0.0f, 0.0f, 0.0f, D3DCOLOR_ARGB(255,255,255,255));

				CSGD_TextureManager::GetInstance()->Draw(PanelID, 30, 85, 3.5f, 1.5f, &GUItop, 0.0f, 0.0f, 0.0f, D3DCOLOR_ARGB(255,255,255,255));
				CSGD_TextureManager::GetInstance()->Draw(PanelID, 30, 122, 3.5f, 0.8f, &GUImid, 0.0f, 0.0f, 0.0f, D3DCOLOR_ARGB(255,255,255,255));
				CSGD_TextureManager::GetInstance()->Draw(PanelID, 30, 160, 3.5f, 1.5f, &GUIbot, 0.0f, 0.0f, 0.0f, D3DCOLOR_ARGB(255,255,255,255));

				CSGD_TextureManager::GetInstance()->Draw(PanelID, 165, 210, 2.0f, 1.6f, &GUItop, 0.0f, 0.0f, 0.0f, D3DCOLOR_ARGB(255,255,255,255));
				CSGD_TextureManager::GetInstance()->Draw(PanelID, 165, 255, 2.0f, 2.2f, &GUImid, 0.0f, 0.0f, 0.0f, D3DCOLOR_ARGB(255,255,255,255));
				CSGD_TextureManager::GetInstance()->Draw(PanelID, 165, 355, 2.0f, 1.6f, &GUIbot, 0.0f, 0.0f, 0.0f, D3DCOLOR_ARGB(255,255,255,255));

				CSGD_TextureManager::GetInstance()->Draw(PanelID, 30, 431, 3.5f, 1.2f, &GUItop, 0.0f, 0.0f, 0.0f, D3DCOLOR_ARGB(255,255,255,255));
				CSGD_TextureManager::GetInstance()->Draw(PanelID, 30, 465, 3.5f, 1.2f, &GUIbot, 0.0f, 0.0f, 0.0f, D3DCOLOR_ARGB(255,255,255,255));

				// Dice Roll info
				Font.Print("Dice Rolls", 250, 10, 2.0f);
				Font.Print("When attacking another character, damage is determined via ", 55, 90, 1.0f);
				Font.Print("subtracting dice rolls representing offense and defense. ", 55, 150, 1.0f);
				Font.Print("Attack" , 190, 215, 2.0f);
				RECT d2 = {68,5,124,47};
				RECT d1 = {5,5,56,47};
				CSGD_TextureManager::GetInstance()->Draw(DiceID, 240, 280, 1.0f,1.0f,&d2);
				CSGD_TextureManager::GetInstance()->Draw(DiceID, 410, 280, 1.0f,1.0f,&d1);
				Font.Print("--", 330, 220, 2.0f);
				Font.Print("Defense" , 370, 215, 2.0f);
				Font.Print("= 1 damage", 220, 335, 2.0f);
				Font.Print("The attack roll is on the left and defense is on the right. ", 55, 445, 1.0f);
				break;
			}
		case 3:
			{
				CSGD_TextureManager::GetInstance()->Draw(PanelID, 250, 5, 1.5f, 1.5f, &GUItop, 0.0f, 0.0f, 0.0f, D3DCOLOR_ARGB(255,255,255,255));
				CSGD_TextureManager::GetInstance()->Draw(PanelID, 250, 45, 1.5f, 1.2f, &GUIbot, 0.0f, 0.0f, 0.0f, D3DCOLOR_ARGB(255,255,255,255));

				CSGD_TextureManager::GetInstance()->Draw(PanelID, 80, 90, 3.0f, 1.5f, &GUItop, 0.0f, 0.0f, 0.0f, D3DCOLOR_ARGB(255,255,255,255));
				CSGD_TextureManager::GetInstance()->Draw(PanelID, 80, 130, 3.0f, 1.2f, &GUIbot, 0.0f, 0.0f, 0.0f, D3DCOLOR_ARGB(255,255,255,255));

				CSGD_TextureManager::GetInstance()->Draw(PanelID, 0, 175, 3.9f, 2.2f, &GUItop, 0.0f, 0.0f, 0.0f, D3DCOLOR_ARGB(255,255,255,255));
				CSGD_TextureManager::GetInstance()->Draw(PanelID, 0, 237, 3.9f, 2.5f, &GUImid, 0.0f, 0.0f, 0.0f, D3DCOLOR_ARGB(255,255,255,255));
				CSGD_TextureManager::GetInstance()->Draw(PanelID, 0, 350, 3.9f, 2.2f, &GUIbot, 0.0f, 0.0f, 0.0f, D3DCOLOR_ARGB(255,255,255,255));

				// Weather info 
				Font.Print("Weather", 295, 10, 2.0f);
				Font.Print("There are 3 weather patterns that can affect tiles:", 100, 105, 1.0f);
				Font.Print("Rain", 40, 185, 2.0f);
				Font.Print("Snow", 300, 185, 2.0f);
				Font.Print("Sunny", 560, 185, 2.0f);
				RECT grass = {0,0,64,64};
				RECT dirt = {64,0,128,64};
				RECT water = {320,0,384,64};
				RECT snow = {128,64,192,128};
				RECT mud = {384,0,448,64};

				// Rain effects
				CSGD_TextureManager::GetInstance()->Draw(TileSheet,40,250,1.0f,1.0f,&grass);
				Font.Print(">>", 110, 250, 2.0f);
				CSGD_TextureManager::GetInstance()->Draw(TileSheet,175,250,1.0f,1.0f,&water);
				CSGD_TextureManager::GetInstance()->Draw(TileSheet,40,320,1.0f,1.0f,&dirt);
				Font.Print(">>", 110, 320, 2.0f);
				CSGD_TextureManager::GetInstance()->Draw(TileSheet,175,320,1.0f,1.0f,&mud);

				// Snow effects
				CSGD_TextureManager::GetInstance()->Draw(TileSheet,300,250,1.0f,1.0f,&grass);
				Font.Print(">>", 370, 250, 2.0f);
				CSGD_TextureManager::GetInstance()->Draw(TileSheet,435,250,1.0f,1.0f,&snow);
				CSGD_TextureManager::GetInstance()->Draw(TileSheet,300,320,1.0f,1.0f,&dirt);
				Font.Print(">>", 370, 320, 2.0f);
				CSGD_TextureManager::GetInstance()->Draw(TileSheet,435,320,1.0f,1.0f,&snow);

				// Sunny effects
				CSGD_TextureManager::GetInstance()->Draw(TileSheet,560,250,1.0f,1.0f,&water);
				Font.Print(">>", 630, 250, 2.0f);
				CSGD_TextureManager::GetInstance()->Draw(TileSheet,695,250,1.0f,1.0f,&grass);
				CSGD_TextureManager::GetInstance()->Draw(TileSheet,560,320,1.0f,1.0f,&snow);
				Font.Print(">>", 630, 320, 2.0f);
				CSGD_TextureManager::GetInstance()->Draw(TileSheet,695,320,1.0f,1.0f,&grass);
				break;
			}
		case 4:
			{
				CSGD_TextureManager::GetInstance()->Draw(PanelID, 170, 5, 2.0f, 1.5f, &GUItop, 0.0f, 0.0f, 0.0f, D3DCOLOR_ARGB(255,255,255,255));
				CSGD_TextureManager::GetInstance()->Draw(PanelID, 170, 45, 2.0f, 1.2f, &GUIbot, 0.0f, 0.0f, 0.0f, D3DCOLOR_ARGB(255,255,255,255));
				
				CSGD_TextureManager::GetInstance()->Draw(PanelID, 0, 85, 3.9f, 3.0f, &GUItop, 0.0f, 0.0f, 0.0f, D3DCOLOR_ARGB(255,255,255,255));
				CSGD_TextureManager::GetInstance()->Draw(PanelID, 0, 155, 3.9f, 3.0f, &GUImid, 0.0f, 0.0f, 0.0f, D3DCOLOR_ARGB(255,255,255,255));
				CSGD_TextureManager::GetInstance()->Draw(PanelID, 0, 248, 3.9f, 3.0f, &GUImid, 0.0f, 0.0f, 0.0f, D3DCOLOR_ARGB(255,255,255,255));
				CSGD_TextureManager::GetInstance()->Draw(PanelID, 0, 360, 3.9f, 3.0f, &GUImid, 0.0f, 0.0f, 0.0f, D3DCOLOR_ARGB(255,255,255,255));
				CSGD_TextureManager::GetInstance()->Draw(PanelID, 0, 500, 3.9f, 3.0f, &GUIbot, 0.0f, 0.0f, 0.0f, D3DCOLOR_ARGB(255,255,255,255));

				// Tile info
				Font.Print("Tile Effects", 260, 10, 2.0f);
				RECT grass = {0,0,64,64};
				RECT dirt = {64,0,128,64};
				RECT water = {320,0,384,64};
				RECT snow = {128,64,192,128};
				RECT mud = {384,0,448,64};
				RECT wall = {192,0,256,64};
				RECT floor = {128,0,192,64};
				RECT rocks = {0,64,64,128};
				RECT mtn = {64,64,128,128};
				RECT shrub = {192,64,256,128};
				RECT crowd = {320,64,384,128};
				RECT pillar = {256,64,320,128};
				RECT tree = {256,0,320,64};
				RECT lava = {448,0,512,64};

				// No Effect tiles
				CSGD_TextureManager::GetInstance()->Draw(TileSheet,20,100,1.0f,1.0f,&grass);
				CSGD_TextureManager::GetInstance()->Draw(TileSheet,90,100,1.0f,1.0f,&dirt);
				CSGD_TextureManager::GetInstance()->Draw(TileSheet,160,100,1.0f,1.0f,&floor);
				Font.Print("These tiles have no effect", 234, 100, 2.0f);

				// Obstacle tiles
				CSGD_TextureManager::GetInstance()->Draw(TileSheet,20,200,1.0f,1.0f,&wall);
				CSGD_TextureManager::GetInstance()->Draw(TileSheet,90,200,1.0f,1.0f,&tree);
				CSGD_TextureManager::GetInstance()->Draw(TileSheet,160,200,1.0f,1.0f,&rocks);
				CSGD_TextureManager::GetInstance()->Draw(TileSheet,230,200,1.0f,1.0f,&mtn);
				CSGD_TextureManager::GetInstance()->Draw(TileSheet,300,200,1.0f,1.0f,&pillar);
				CSGD_TextureManager::GetInstance()->Draw(TileSheet,370,200,1.0f,1.0f,&crowd);
				Font.Print("Obstacles", 450, 200, 2.0f);

				// Effect tiles
				CSGD_TextureManager::GetInstance()->Draw(TileSheet,20,295,1.0f,1.0f,&water);
				Font.Print("-1 Movement Range", 100, 295, 2.0f);
				CSGD_TextureManager::GetInstance()->Draw(TileSheet,20,435,1.0f,1.0f,&mud);
				Font.Print("-1 Movement Range", 100, 435, 2.0f);
				CSGD_TextureManager::GetInstance()->Draw(TileSheet,20,365,1.0f,1.0f,&shrub);
				Font.Print("+25% To Defense", 100, 365, 2.0f);
				CSGD_TextureManager::GetInstance()->Draw(TileSheet,20,505,1.0f,1.0f,&lava);
				Font.Print("-50% To All Stats", 100, 505, 2.0f);
				break;
			}
		}
	}
}

void HowToPlayState::Exit(void)
{
	CSGD_XAudio2::GetInstance()->MusicStopSong(BGMID);

	if(PanelID != -1)
	{
		CSGD_TextureManager::GetInstance()->UnloadTexture(PanelID);
		PanelID = -1;
	}

	if(BGMID != -1)
	{
		CSGD_XAudio2::GetInstance()->MusicUnloadSong(BGMID);
		BGMID = -1;
	}

	if(CursorID != -1)
	{
		CSGD_TextureManager::GetInstance()->UnloadTexture(CursorID);
		CursorID = -1;
	}

	if(BackgroundID != -1)
	{
		CSGD_TextureManager::GetInstance()->UnloadTexture(BackgroundID);
		BackgroundID = -1;
	}

	if(FontID != -1)
	{
		CSGD_TextureManager::GetInstance()->UnloadTexture(FontID);
		FontID = -1;
	}

	if(LeftID != -1)
	{
		CSGD_TextureManager::GetInstance()->UnloadTexture(LeftID);
		LeftID = -1;
	}

	if(RightID != -1)
	{
		CSGD_TextureManager::GetInstance()->UnloadTexture(RightID);
		RightID = -1;
	}

	if(UpID != -1)
	{
		CSGD_TextureManager::GetInstance()->UnloadTexture(UpID);
		UpID = -1;
	}

	if(DownID != -1)
	{
		CSGD_TextureManager::GetInstance()->UnloadTexture(DownID);
		DownID = -1;
	}

	if(EnterID != -1)
	{
		CSGD_TextureManager::GetInstance()->UnloadTexture(EnterID);
		EnterID = -1;
	}

	if(EscID != -1)
	{
		CSGD_TextureManager::GetInstance()->UnloadTexture(EscID);
		EscID = -1;
	}

	if(ShiftID != -1)
	{
		CSGD_TextureManager::GetInstance()->UnloadTexture(ShiftID);
		ShiftID = -1;
	}

	if(DiceID != -1)
	{
		CSGD_TextureManager::GetInstance()->UnloadTexture(DiceID);
		DiceID = -1;
	}

	if(TileSheet != -1)
	{
		CSGD_TextureManager::GetInstance()->UnloadTexture(TileSheet);
		TileSheet = -1;
	}

	DeleteInstance();
}

void HowToPlayState::ArcadeInput()
{
	arcadeEnter = false;
	arcadeEscape = false;
	arcadeUp = false;
	arcadeDown = false;
	arcadeLeft = false;
	arcadeRight = false;
	arcadeBackspace = false;
	arcadeShift = false;
	arcadePlus = false;
	arcadeMinus = false;
	arcadeP = false;

	CSGD_DirectInput * di = CSGD_DirectInput::GetInstance();

	if(di->JoystickGetLStickDirPressed(DIR_UP,0))
	{
		arcadeUp = true;
	}

	if(di->JoystickGetLStickDirPressed(DIR_DOWN,0))
	{
		arcadeDown = true;
	}

	if(di->JoystickGetLStickDirPressed(DIR_LEFT,0))
	{
		arcadeLeft = true;
	}

	if(di->JoystickGetLStickDirPressed(DIR_RIGHT,0))
	{
		arcadeRight = true;
	}

	if(di->JoystickButtonPressed(0,0))
	{
		arcadeEnter = true;
	}

	if(di->JoystickButtonPressed(1,0))
	{
		arcadeBackspace = true;
	}

	if(di->JoystickButtonPressed(2,0))
	{
		arcadeP = true;
	}

	if(di->JoystickButtonPressed(3,0))
	{
		arcadeShift = true;
	}

	if(di->JoystickButtonPressed(4,0))
	{
		arcadePlus = true;
	}

	if(di->JoystickButtonPressed(5,0))
	{
		arcadeMinus = true;
	}

	if(di->JoystickButtonPressed(6,0))
	{
		arcadeEscape = true;
	}
}
